
import DepartAPI from '../api/depart.js';

export const Depart={
   state:{
      departlist:[],
      depart_checked_id:-1,
      getDepartDataStatus:-1
   },
   mutations:{
      setDepartList(state,list){
          state.departlist=list;
      },
      setDepartCheckedId(state,id){
          state.depart_checked_id=id;
      },
      setDepartDataStatus(state,status){
          state.getDepartDataStatus=status;
      }
   },
   actions:{
      loadDepartList(context,data){
          DepartAPI.getDepartList(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setDepartList',response.data.data.list);
              }
          })
      },
      loadDepartData(context,data){
          DepartAPI.getDepartData(data).then(function(response){
              context.commit('setDepartDataStatus',response.data.code);
          })
      }
   },
   getters:{
      getDepartList:state =>{
         return state.departlist
      },
      getDepartCheckedId:state => {
         return state.depart_checked_id
      },
      getDepartDataStatus:state => {
         return state.getDepartDataStatus;
      }
   }
}
